<template>
  <div class="container">
    <div class="items" v-for="item in data" :key="item.id" :class="[cur == item.id? 'active': '']"
         @click="toAnther(item.id)">
      {{ item.address }}
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      cur: 1,
      data: [
        {
          id: 1,
          address: "全市"
        },
        {
          id: 2,
          address: "盐化新区"
        },
        {
          id: 3,
          address: "洪泽县"
        },
        {
          id: 4,
          address: "涟水县"
        },
        {
          id: 5,
          address: "金湖县"
        },
        {
          id: 6,
          address: "清江浦区"
        }
      ]
    };
  },
  methods: {
    toAnther(id) {
      this.cur = id;
    }
  }
};
</script>

<style lang="scss" scoped>
* {
  margin: 0;
  padding: 0;
}

.container {
  display: flex;
  padding-top: 20px;
  margin-left: 27px;

  .items:first-child {
    position: relative;
    padding: 10px 20px;
    font-size: 16px;
    line-height: 10px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #5d6c8e;
    background: #ffffff;
    border: 1px solid #e3e6ec;
    border-radius: 6px 0 0 6px;
    text-align: center;
    cursor: pointer;
  }

  .items:last-child {
    position: relative;
    padding: 10px 20px;
    font-size: 16px;
    line-height: 10px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #5d6c8e;
    background: #ffffff;
    border: 1px solid #e3e6ec;
    border-radius: 0 6px 6px 0;
    cursor: pointer;
  }

  .items:not(:first-child):not(:last-child) {
    position: relative;
    padding: 10px 20px;
    font-size: 16px;
    line-height: 10px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #5d6c8e;
    background: #ffffff;
    border: 1px solid #e3e6ec;
    cursor: pointer;
  }

  .active {
    background: #5184EA !important;
    color: #FEFEFE !important;

    &::before {
      content: '';
      position: absolute;
      top: 30px;
      left: 50%;
      border-top: 5px solid #5184EA;
      border-left: 5px solid transparent;
      border-bottom: 5px solid transparent;
      border-right: 5px solid transparent;
    }
  }
}
</style>